#pragma once
#include "GDxPreInclude.h"
#include <wrl/client.h>

struct ProfileData
{
	std::string name;
	float time;
};

class GDxGpuProfiler
{
	template<typename T>
	using ComPtr = Microsoft::WRL::ComPtr<T>;
public:
	static GDxGpuProfiler& Get();

	void Initialize(ID3D11Device* pDevice,ID3D11DeviceContext* pContext,int num = 10);

	void BeginFrame();

	void EndFrame();

	void StartGpuProfile(const std::string& profileName);

	void EndGpuProfile(const std::string& profileName);

	const std::vector<ProfileData>& GetProfileDatas();
	const double GetAllPassTime() { return mSumPass; };

private:
	GDxGpuProfiler() {};
	~GDxGpuProfiler() {};

	ComPtr<ID3D11Query>mQD;
	std::vector<ComPtr<ID3D11Query>> mQTSs;
	ID3D11DeviceContext* mpContext = nullptr;

	std::vector<ProfileData> mProfileDatas;
	std::unordered_map<std::string, size_t> mProfileMap;

	double mSumPass = 0;
};

